#导入包
from django.template.library import Library

#创建注册过滤器对象
register = Library()

#注册过滤器
@register.filter
def filter_phone1(value):
    """自定义过滤器，手机号隐藏4位"""
    return value[:3] + "*" * 4 + value[-4:]


@register.filter
def filter_phone2(value, length):
    """自定义过滤器，手机号隐藏后length位"""
    return value[:11 - length] + "*" * length
